#pragma once
#include <array>
#include <string_view>

#include "ICommand.h"

#ifdef _DEBUG
#include "Commands/TestCommand.h"
#include "Commands/DLLInjectorCommand.h"
#include "Commands/OptionCommand.h"

#endif  // _DEBUG

#include "Commands/EjectCommand.h"
#include "Commands/HelpCommand.h"
#include "Commands/ConfigCommand.h"
#include "Commands/BindCommand.h"
#include "Commands/UnbindCommand.h"
#include "Commands/TranslateCommand.h"
#include "Commands/FriendCommand.h"
#include "Commands/ServerCommand.h"
#include "Commands/SetPrefixCommand.h"
#include "Commands/CoordsCommand.h"
#include "Commands/ToggleCommand.h"
#include "Commands/SetLanguageCommand.h"
#include "Commands/AutoTextCommand.h"
#include "Commands/SayCommand.h"

#ifdef _DEBUG
static constexpr size_t numOfCommands = 17;
#else
static constexpr size_t numOfCommands = 15;
#endif

class ICommand;
class CommandMgr {
public:
	static constexpr std::array<ICommand*, numOfCommands /*num of commands*/> commandList {
#ifdef _DEBUG
		&TestCommand,
		&DLLInjectorCommand, 
		&OptionCommand,
#endif  // _DEBUG
		&AutoTextCommand,
		&BindCommand,
		&ConfigCommand,
		&CoordsCommand,
		&EjectCommand,
		&FriendCommand,
		&HelpCommand,
		&OptionCommand,
		&SayCommand,
		&ServerCommand,
		&SetLanguageCommand,
		&SetPrefixCommand,
		&ToggleCommand,
		&TranslateCommand,
		&UnbindCommand
	};
	static std::map<std::u8string, ICommand*> NameTable;

	static char8_t prefix;

public:
	static constexpr size_t getCommandsCount() {
		size_t i = 0;
		for (; i < commandList.size(); i++)
			if (commandList[i] == nullptr) [[unlikely]]
				break;
		return i;
	}

	static void initCommands();
	static void disable();
	static void execute(std::u8string_view message);
	static size_t dp(const std::u8string_view x, const std::u8string_view y);
};
